package com.spider.silence.job;

import com.spider.silence.downloader.TencentWeiBoDownloader;
import com.spider.silence.pool.TencentWeiBoDownLoaderPool;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.StatefulJob;

/**
 * @author liyuanguo
 * @version V1.0
 * @time 2017/2/14 10:56
 * @description
 */
public class TencentWeiBoJob implements StatefulJob {
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        TencentWeiBoDownloader downLoader=null;
        try {
            while(true){
                downLoader=TencentWeiBoDownLoaderPool.getInstance().fetchDownLoader(1000);
                if(null!=downLoader){
                    break;
                }
            }
            downLoader.generateTask();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }finally {
            TencentWeiBoDownLoaderPool.getInstance().releaseDownLoader(downLoader);
        }
    }
}
